﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TaxiOnline.DAL.DataLayers;
using TaxiOnline.DAL.Models;
using TaxiOnline.DAL.Repositories;

namespace TaxiOnline
{
    class Program
    {
        static void Main(string[] args)
        {
            //TaxiContext db = TaxiDbContext.Context;
            
            
            ////Street street = new Street(-1, "Soborna", null);
            ////Region region = new Region(-1, "Center", null, new List<Street>());
            ////City city = new City(-1, "Rivne", new List<Region>());

            ////city.Regions.Add(region);
            ////region.City = city;
            ////street.Region = region;
            ////region.Streets.Add(street);

            
            ////db.Cities.Add(city);
            ////db.Regions.Add(region);
            ////db.Streets.Add(street);
            
            ////db.SaveChanges();
            //City c = db.Cities.Where(c1 => c1.Name == "Рівне").First();
            //Region reg = c.Regions.Where(c2 => c2.Id > 0).First();
            

            //Console.WriteLine(reg.City.Name);

            UserRepository rep = new UserRepository();
            User user = rep.GetUserById(1);
            Driver driver = rep.GetDriverById(1);
            LoginReturnType ret = rep.Login(user.Login, user.Password);
            ShowMsg(ret);


            ret = rep.Login(driver.Login, driver.Password);
            ShowMsg(ret);

            ret = rep.Login("asdg", "adshdsh");
            ShowMsg(ret);
           
            

           // Console.WriteLine("Press any key to exit...");
           // Console.ReadKey(); 
        }

        static void ShowMsg(LoginReturnType ret){
            switch (ret) 
                {
                    case LoginReturnType.User:
                        Console.WriteLine("Logged as user");
                        break;
                    case LoginReturnType.Driver:
                        Console.WriteLine("Logged as driver");
                        break;
                    case LoginReturnType.InvalidData:
                        Console.WriteLine("Invalid data");
                        break;
                }
        
        }
    }
}
